package com.fengycx.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fengycx.constants.Constants;
import com.fengycx.pojo.domain.Driver;
import com.fengycx.pojo.domain.DriverAuthMaterial;
import com.fengycx.pojo.domain.DriverSummary;
import com.fengycx.mapper.DriverSummaryMapper;
import com.fengycx.pojo.vo.DriverWorkbenchVo;
import com.fengycx.service.IDriverAuthMaterialService;
import com.fengycx.service.IDriverService;
import com.fengycx.service.IDriverSummaryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fengycx.utils.BitStatesUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 司机结算对象 服务实现类
 * </p>
 *
 * @author Cino
 * @since 2024-02-19
 */
@Service
public class DriverSummaryServiceImpl extends ServiceImpl<DriverSummaryMapper, DriverSummary> implements IDriverSummaryService {

    @Autowired
    @Lazy
    private IDriverService driverService;

    @Override
    public DriverWorkbenchVo getWorkbench() {
        long driverId = StpUtil.getLoginIdAsLong();
        Driver driver = driverService.getById(driverId);
        //判断司机是否认证成功
        boolean state = BitStatesUtil.hasState(driver.getBitState(), BitStatesUtil.OP_REAL_AUTHENTICATIONED);
        DriverWorkbenchVo driverWorkbenchVo = new DriverWorkbenchVo();
        if(state){
            DriverSummary summary = super.getById(driverId);
            BeanUtil.copyProperties(summary,driverWorkbenchVo);
            driverWorkbenchVo.setRealAuthSuccess(true);
        }
        return driverWorkbenchVo;
    }
}
